<?php
	function emailCreateMessage($matches,$ads) {
		global $globalDebug;
		
		$message = "";
		
		$message .= "Följande annonser är relevanta för dina auktionsbevakningar.\n\n";
		
		foreach ($matches as $ad_id) {
			$ad = $ads[$ad_id];
			$message .= $ad['id'].", ".$ad['title']."\n";
		}
		
		$message .= "\n\n";
		$message .= "Mvh Trading On Rails";
		
		$query = mysql_query("SELECT * FROM ad_categories");
		$result = array();
		while ($data = mysql_fetch_assoc($query)) {
			$result[$data['category_id']][] = $data['ad_id'];
		}
		
		
		if ($globalDebug) {
			print "$message\n";
		}
		return $message;
	}
	
	function emailEmail($observer, $matches, $ads) {
		$message = emailCreateMessage($matches, $ads);
		$subject = count($matches)." new ads";
		databaseQueueEmail($observer,$subject,$message);
	}
?>
